package com.kasax.skin.support.corel;

import android.app.Activity;
import android.app.Application;
import android.graphics.Typeface;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.kasax.skin.support.utils.LayoutFactoryCompatHelper;
import com.kasax.skin.support.utils.LogUtils;

public class SkinActivityLifecycle implements Application.ActivityLifecycleCallbacks {

    @Override
    public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
        LogUtils.i(getClass(), "onActivityCreated");
        // 更新状态栏
        SkinThemeUtils.updateStatusBarColor(activity);

        // 获取要换肤的字体
        Typeface skinTypeFace = SkinThemeUtils.getSkinTypeface(activity);

        LayoutFactoryCompatHelper.compatInstallLayoutFactory(activity,skinTypeFace);
    }


    @Override
    public void onActivityStarted(@NonNull Activity activity) {
        LogUtils.i(getClass(), "onActivityStarted");
    }

    @Override
    public void onActivityResumed(@NonNull Activity activity) {
        LogUtils.i(getClass(), "onActivityResumed");
    }

    @Override
    public void onActivityPaused(@NonNull Activity activity) {
        LogUtils.i(getClass(), "onActivityPaused");
    }

    @Override
    public void onActivityStopped(@NonNull Activity activity) {
        LogUtils.i(getClass(), "onActivityStopped");
    }

    @Override
    public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
        LogUtils.i(getClass(), "onActivitySaveInstanceState");
    }

    @Override
    public void onActivityDestroyed(@NonNull Activity activity) {
        LogUtils.i(getClass(), "onActivityDestroyed");
        LayoutFactoryCompatHelper.remove(activity);
    }


}
